<?php

if (!function_exists('route_class')) {
    function route_class()
    {
        return str_replace('.', '-', Route::currentRouteName());
    }
}

if (!function_exists('make_excerpt')) {
    function make_excerpt($value, $length = 200)
    {
        $excerpt = trim(preg_replace('/\r\n|\r|\n+/', ' ', strip_tags($value)));
        return str_limit($excerpt, $length);
    }
}

/*进制转换*/
if (!function_exists('to_size')) {
    function to_size($value, $num = 2)
    {
        if ($num == 1) {
            $value = $value / 1024;
        }
        if ($num == 2) {
            $value = $value / 1024 / 1024;
        }
        if ($num == 3) {
            $value = $value / 1024 / 1024 / 1024;
        }
        return round($value, 2);
    }
}
